package com.dlc.shop.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.dlc.shop.bean.app.dto.DvyTypeDTO;
import com.dlc.shop.bean.app.dto.ShopCartItemDto;
import com.dlc.shop.bean.dto.StockPointSkuDTO;
import com.dlc.shop.bean.enums.*;
import com.dlc.shop.bean.event.LoadOrderItemGiveawayEvent;
import com.dlc.shop.bean.model.Category;
import com.dlc.shop.bean.model.Product;
import com.dlc.shop.bean.model.ShopDetail;
import com.dlc.shop.bean.model.Sku;
import com.dlc.shop.bean.vo.GiveawayProdVO;
import com.dlc.shop.bean.vo.GiveawayVO;
import com.dlc.shop.bean.vo.VirtualRemarkVO;
import com.dlc.shop.bean.vo.WarehouseVO;
import com.dlc.shop.common.config.Constant;
import com.dlc.shop.common.enums.StatusEnum;
import com.dlc.shop.common.enums.SysTypeEnum;
import com.dlc.shop.common.exception.YamiShopBindException;
import com.dlc.shop.common.util.Arith;
import com.dlc.shop.common.util.BeanUtil;
import com.dlc.shop.common.util.Json;
import com.dlc.shop.dao.BasketMapper;
import com.dlc.shop.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 购物车项数据组装
 *
 * @author FrozenWatermelon
 * @date 2020-11-20 15:47:32
 */
@Slf4j
@Service
public class ShopCartItemServiceImpl implements ShopCartItemService {

    @Autowired
    private ProductService productService;
    @Autowired
    private SkuService skuService;
    @Autowired
    private CategoryShopService categoryShopService;
    @Autowired
    private BasketMapper basketMapper;
    @Autowired
    private SkuComboService skuComboService;
    @Autowired
    private ShopDetailService shopDetailService;
    @Autowired
    private WarehouseService warehouseService;

    @Autowired
    private ApplicationContext applicationContext;

    @Override
    public List<ShopCartItemDto> handleShopCartItem(List<ShopCartItemDto> shopCartItems, List<DvyTypeDTO> dvyTypes, OrderType orderType) {
        // 组装购物车项数据
        this.assembleShopCartItem(shopCartItems, null);


        // 处理组合商品信息
        handleComboShopCart(shopCartItems);

        // 普通订单才有赠品
        if (Objects.equals(orderType, OrderType.ORDINARY)) {
            // 组装赠品信息 - 判断库存及插入赠品数据
            this.buildItemGiveawayInfo(shopCartItems);
        }

        // 插入店铺仓库列表
        this.setWarehouseList(shopCartItems, dvyTypes);

        return shopCartItems;
    }

    @Override
    public List<ShopCartItemDto> getCheckedShopCartItems(String userId, Long addrId, List<DvyTypeDTO> dvyTypes) {
        List<ShopCartItemDto> shopCartItems = basketMapper.getUserShopCartItems(userId);
        shopCartItems.forEach(shopCartItemVO -> shopCartItemVO.setIsChecked(1));
        this.handleShopCartItem(shopCartItems, dvyTypes, OrderType.ORDINARY);
        return shopCartItems;
    }

    @Override
    public void assembleShopCartItem(List<ShopCartItemDto> shopCartItems, ShopCartItemDto mainShopCartItem) {
        List<Long> skuIds = new ArrayList<>(shopCartItems.size());
        for (ShopCartItemDto shopCartItem : shopCartItems) {
            skuIds.add(shopCartItem.getSkuId());
        }
        // 立即提交的套餐没有prodId，所以用sku来获取prodId
        Map<Long, Sku> skuMap = this.mapSkuByCache(skuIds);
        List<Long> prodIds = skuMap.values().stream().map(Sku::getProdId).toList();
        Map<Long, Product> spuMap = this.mapSpuByCache(prodIds);
        Map<Long, ShopDetail> shopMap = new HashMap<>(Constant.INITIAL_CAPACITY);
        Iterator<ShopCartItemDto> iterator = shopCartItems.iterator();
        while (iterator.hasNext()) {
            ShopCartItemDto shopCartItem = iterator.next();
            Sku sku = skuMap.get(shopCartItem.getSkuId());
            Product prod = spuMap.get(sku.getProdId());

            // 从购物车提交的订单，需要去除失效商品
            if (Objects.nonNull(shopCartItem.getBasketId())) {
                boolean invalidProduct = Objects.isNull(prod) || Objects.isNull(sku) ||
                        !Objects.equals(sku.getStatus(), StatusEnum.ENABLE.value()) ||
                        Objects.equals(sku.getIsDelete(), StatusEnum.ENABLE.value()) ||
                        !Objects.equals(prod.getStatus(), StatusEnum.ENABLE.value()) ||
                        // 购物车的预售商品，且不参与活动时，不能从购物车提交订单
                        (Objects.equals(prod.getPreSellStatus(), StatusEnum.ENABLE.value()) && Objects.isNull(shopCartItem.getComboId()) && shopCartItem.getComboId() == 0);
                if (invalidProduct) {
                    iterator.remove();
                    continue;
                }
            }

            // 填充购物车项基本数据
            handShopCartItemBaseInfo(shopCartItem, prod, sku,mainShopCartItem);

            // 区域库存列表
            shopCartItem.setStockPointList(sku.getStockPointList());

            //设置可售卖库存
            Integer afterStock = 0;
            for (StockPointSkuDTO vo : shopCartItem.getStockPointList()) {
                afterStock += vo.getStock();
            }
            shopCartItem.setAfterStock(afterStock);


            // 预售信息 -- 处理下发货时间
            shopCartItem.setPreSellTime(prod.getPreSellTime());

            // 虚拟商品参数
            handleVirtual(shopCartItem, prod);

            // 店铺信息
            if (0 == prod.getShopId()) {
                shopCartItem.setShopId(Constant.PLATFORM_SHOP_ID);
                shopCartItem.setShopName(Constant.PLATFORM_SHOP_NAME);
            } else {
                ShopDetail shopDetail = shopMap.get(prod.getShopId());
                if (Objects.isNull(shopDetail)) {
                    shopDetail = shopDetailService.getShopDetailByShopId(prod.getShopId());
                    shopMap.put(prod.getShopId(), shopDetail);
                }
                if (!Objects.equals(shopDetail.getShopStatus(), ShopStatus.OPEN.value())) {
                    // 店铺不处于营业状态
                    throw new YamiShopBindException("yami.store.shop.state.check");
                }
                shopCartItem.setShopId(shopDetail.getShopId());
                shopCartItem.setShopName(shopDetail.getShopName());
            }
        }

        // 订单项赠品数据
        applicationContext.publishEvent(new LoadOrderItemGiveawayEvent(shopCartItems));

        // 订单项金额从小到大排序
        shopCartItems.sort(Comparator.comparingDouble(ShopCartItemDto::getActualTotal));
    }


    private static void handleVirtual(ShopCartItemDto shopCartItem, Product prod) {
        if (!Objects.equals(prod.getMold(), 1)) {
            return;
        }
        shopCartItem.setWriteOffNum(prod.getWriteOffNum());
        shopCartItem.setWriteOffMultipleCount(prod.getWriteOffMultipleCount());
        shopCartItem.setWriteOffStart(prod.getWriteOffStart());
        shopCartItem.setWriteOffEnd(prod.getWriteOffEnd());
        shopCartItem.setWriteOffTime(prod.getWriteOffTime());
        shopCartItem.setIsRefund(prod.getIsRefund());
        // 如果没有备注，虚拟商品数据已经处理完成
        if (StrUtil.isBlank(prod.getVirtualRemark())) {
            return;
        }
        List<VirtualRemarkVO> virtualRemarkList = JSONUtil.parseArray(prod.getVirtualRemark()).toList(VirtualRemarkVO.class);
        for (VirtualRemarkVO virtualRemarkVO : virtualRemarkList) {
            if(virtualRemarkVO.getIsRequired() == null){
                virtualRemarkVO.setIsRequired(false);
            }
            virtualRemarkVO.setProdId(shopCartItem.getProdId());
        }
        shopCartItem.setVirtualRemarkList(virtualRemarkList);
    }

    private static void handShopCartItemBaseInfo(ShopCartItemDto shopCartItem, Product prod, Sku sku, ShopCartItemDto mainShopCartItem) {
        if (Objects.isNull(shopCartItem.getBasketId())) {
            // 立即购买的订单
            shopCartItem.setBasketId(-1L);
        }
        if(Objects.nonNull(shopCartItem.getMainComboSkuId())) {
//            // 组合商品信息 -- 设置一下组合主商品信息
//            shopCartItem.setComboAmount(shopCartItem.getSkuPriceFee() * shopCartItem.getCount() * shopCartItem.getComboCount());
//            shopCartItem.setTotalAmount(shopCartItem.getCount() * shopCartItem.getSkuPriceFee() * shopCartItem.getComboCount());
            shopCartItem.setComboCount(shopCartItem.getProdCount() * mainShopCartItem.getProdCount());
            shopCartItem.setProdCount(shopCartItem.getComboCount());
        }
        // prod
        shopCartItem.setProdId(prod.getProdId());
        shopCartItem.setProdType(prod.getProdType());
        shopCartItem.setCategoryId(prod.getCategoryId());
        shopCartItem.setProdCount(shopCartItem.getProdCount());
        shopCartItem.setMold(Objects.isNull(prod.getMold()) ? 0 : prod.getMold());
        shopCartItem.setProdName(prod.getProdName());
        shopCartItem.setCategoryId(prod.getCategoryId());
        shopCartItem.setPreSellTime(Objects.equals(prod.getPreSellStatus(), 1) ? prod.getPreSellTime() : null);
        shopCartItem.setPreSellStatus(prod.getPreSellStatus());
        shopCartItem.setDeliveryMode(prod.getDeliveryMode());
        shopCartItem.setDeliveryTemplateId(prod.getDeliveryTemplateId());
        shopCartItem.setDeliveryAmount(prod.getDeliveryAmount());
        Product.DeliveryModeVO deliveryModeVO = Json.parseObject(prod.getDeliveryMode(), Product.DeliveryModeVO.class);
        shopCartItem.setDeliveryModeVO(deliveryModeVO);
        // sku
        shopCartItem.setSkuId(sku.getSkuId());
        shopCartItem.setSkuName(sku.getSkuName());
        shopCartItem.setProperties(sku.getProperties());
        //shopCartItem.setBasketDate(new Date());
        shopCartItem.setDistributionCardNo(shopCartItem.getDistributionCardNo());
        if (Objects.isNull(shopCartItem.getDiscountId())) {
            shopCartItem.setDiscountId(0L);
        }
        shopCartItem.setVolume(sku.getVolume());
        shopCartItem.setWeight(sku.getWeight());

        if (Objects.equals(prod.getProdType(), ProdType.PROD_TYPE_SCORE.value())) {
            shopCartItem.setScorePrice(sku.getSkuScore() * shopCartItem.getProdCount());
        }
        shopCartItem.setPic(StrUtil.isBlank(sku.getPic()) ? prod.getPic() : sku.getPic());

        // 处理订单项的活动价格
        if (Objects.isNull(shopCartItem.getPrice()) || shopCartItem.getPrice() < 0) {
            // 普通订单sku价格
            shopCartItem.setPrice(sku.getPrice());
            shopCartItem.setSupplierPrice(sku.getSupplierPrice());
            // 初始化商品实际金额
            shopCartItem.setShareReduce(0.0);
            shopCartItem.setProductTotalAmount(Arith.mul(sku.getPrice(), shopCartItem.getProdCount()));
            shopCartItem.setActualTotal(shopCartItem.getProductTotalAmount());
        } else {
            // 如果有活动价并且活动价大于0则使用活动价格
            // 商品实际金额(优惠金额),在外面就放入shopCartItem中了
            shopCartItem.setActualTotal(Arith.mul(shopCartItem.getProdCount(), shopCartItem.getPrice()));
            // 如果活动价大于商品价格，则设置下原价
            if (shopCartItem.getPrice() > sku.getPrice()) {
                shopCartItem.setProductTotalAmount(Arith.mul(shopCartItem.getPrice(), shopCartItem.getProdCount()));
            } else {
                shopCartItem.setProductTotalAmount(Arith.mul(sku.getPrice(), shopCartItem.getProdCount()));
            }
            double shareReduce = Math.max(Arith.sub(shopCartItem.getProductTotalAmount(), shopCartItem.getActualTotal()), 0.0);
            shopCartItem.setShareReduce(shareReduce);
        }
    }

    private void buildItemGiveawayInfo(List<ShopCartItemDto> shopCartItems) {
        if (CollUtil.isEmpty(shopCartItems)) {
            return;
        }
        List<Long> skuIds = new ArrayList<>(Constant.INITIAL_CAPACITY);
        List<ShopCartItemDto> shopCartItemList = new ArrayList<>(shopCartItems.size());
        for (ShopCartItemDto shopCartItem : shopCartItems) {
            // 没有赠品要处理
            if (Objects.isNull(shopCartItem.getGiveaway())) {
                continue;
            }
            GiveawayVO giveaway = shopCartItem.getGiveaway();
            // 主商品购买数量是否满足赠送的最低要求
            int prodCount = shopCartItem.getProdCount();
            if (Objects.nonNull(shopCartItem.getComboCount()) && shopCartItem.getComboCount() > 0) {
                // 如果是套餐商品，此处的商品数量 = 套餐内商品搭配数量 * 套餐数量
                prodCount *= shopCartItem.getComboCount();
            }
            if (prodCount < giveaway.getBuyNum()) {
                continue;
            }
            for (GiveawayProdVO giveawayProdVO : giveaway.getGiveawayProds()) {
                if (skuIds.contains(giveawayProdVO.getSkuId())) {
                    continue;
                }
                Long skuId = giveawayProdVO.getSkuId();
                skuIds.add(skuId);
                shopCartItemList.add(new ShopCartItemDto(giveawayProdVO.getProdId(), giveawayProdVO.getSkuId(), giveawayProdVO.getGiveawayNum()));
            }
        }

        // 没有赠品，直接返回
        if (CollUtil.isEmpty(shopCartItemList)) {
            return;
        }
        // 组装赠品的spu和sku信息
        this.assembleShopCartItem(shopCartItemList, null);

        Map<Long, ShopCartItemDto> shopCartItemMap = shopCartItemList.stream().collect(Collectors.toMap(ShopCartItemDto::getSkuId, Function.identity()));

        // 将组装好的赠品数据，放入购物车项
        for (ShopCartItemDto shopCartItem : shopCartItems) {
            // 没有赠品要处理,或者主商品购买数量不满足赠送的最低要求
            int prodCount = shopCartItem.getProdCount();
            if (Objects.nonNull(shopCartItem.getComboCount()) && shopCartItem.getComboCount() > 0) {
                // 如果是套餐商品，此处的商品数量 = 套餐内商品搭配数量 * 套餐数量
                prodCount *= shopCartItem.getComboCount();
            }
            if (Objects.isNull(shopCartItem.getGiveaway()) || prodCount < shopCartItem.getGiveaway().getBuyNum()) {
                continue;
            }

            GiveawayVO giveaway = shopCartItem.getGiveaway();
            // 组装赠品订单项的赠品活动数据
            List<ShopCartItemDto> giveawayShopCartItemList = new ArrayList<>(giveaway.getGiveawayProds().size());
            // 赠品数量 = 主商品数 / 最少购买赠送数量
            int giveawayNum = shopCartItem.getProdCount() / giveaway.getBuyNum();
            for (GiveawayProdVO giveawayProdVO : giveaway.getGiveawayProds()) {
                ShopCartItemDto giveawayShopCartItemVO = shopCartItemMap.get(giveawayProdVO.getSkuId());
                giveawayShopCartItemVO = BeanUtil.map(giveawayShopCartItemVO, ShopCartItemDto.class);
                giveawayShopCartItemVO.setProdCount(giveawayProdVO.getGiveawayNum() * giveawayNum);
                giveawayProdVO.setGiveawayNum(giveawayShopCartItemVO.getProdCount());
                giveawayShopCartItemVO.setGiveawayRefundPrice(giveawayProdVO.getRefundPrice());
                // 根据数量，重新计算赠品金额
                giveawayShopCartItemVO.setActualTotal(giveawayShopCartItemVO.getProdCount() * giveawayShopCartItemVO.getPrice());
                giveawayShopCartItemList.add(giveawayShopCartItemVO);
            }
            shopCartItem.setGiveawayShopCartItemList(giveawayShopCartItemList);
        }
    }

    private Map<Long, Product> mapSpuByCache(List<Long> spuIds) {
        if (CollUtil.isEmpty(spuIds)) {
            return Collections.emptyMap();
        }
        Map<Long, Product> spuMap = new HashMap<>(Constant.INITIAL_CAPACITY);
        if (spuIds.size() == 1) {
            Product product = productService.getProductByProdId(spuIds.get(0));
            spuMap.put(spuIds.get(0),product);
        }else {
//            spuMap.putAll(RedisUtil.mapByIds(CacheNames.PRODUCT_KEY, spuIds, Product.class));
//            spuIds.removeAll(spuMap.keySet());
//            if (CollUtil.isNotEmpty(spuIds)) {
                for (Long spuId : spuIds) {
                    Product product = productService.getProductByProdId(spuId);
                    if (Objects.isNull(product)) {
                        throw new YamiShopBindException("商品不存在或者已删除");
                    }
                    spuMap.put(spuId, product);
                }
//            }
        }
        // 添加分类扣率
        this.loadSpuCategory(spuMap);
        return spuMap;
    }

    private Map<Long, Sku> mapSkuByCache(List<Long> skuIds) {
        if (CollUtil.isEmpty(skuIds)) {
            return Collections.emptyMap();
        }
        Map<Long, Sku> skuMap = new HashMap<>(Constant.INITIAL_CAPACITY);
        if (skuIds.size() == 1) {
            Sku sku = skuService.getSkuBySkuId(skuIds.get(0));
            List<Sku> skuList = new ArrayList<>();
            skuList.add(sku);
            skuService.setSkuStock(skuList);
            skuMap.put(skuIds.get(0), skuList.get(0));
            return skuMap;
        }
        //TODO
//        Map<Long, Sku> skuMap = RedisUtil.mapByIds(CacheNames.SKU_KEY, skuIds , Sku.class);
//        skuIds.removeAll(skuMap.keySet());
//        if (CollUtil.isEmpty(skuIds)) {
//            return skuMap;
//        }
        for (Long skuId : skuIds) {
            Sku sku = skuService.getSkuBySkuId(skuId);
            List<Sku> skuList = new ArrayList<>();
            skuList.add(sku);
            skuService.setSkuStock(skuList);
            skuMap.put(skuId, skuList.get(0));
        }
        return skuMap;
    }

    private void loadSpuCategory(Map<Long, Product> spuMap) {
        if (spuMap.isEmpty()) {
            return;
        }
        // 处理一下,获取平台佣金比例
        for (Long spuId : spuMap.keySet()) {
            Product product = spuMap.get(spuId);
            List<Category> shopCategoryRates = categoryShopService.listRateByShopId(product.getShopId());
            product.setRate(0.0);
            for (Category category : shopCategoryRates) {
                if (Objects.equals(category.getCategoryId(), product.getCategoryId())) {
                    product.setRate(category.getDeductionRate());
                }
            }
        }
    }

    private void handleComboShopCart(List<ShopCartItemDto> shopCartItems) {
        List<ShopCartItemDto> comboShopCartItemList = shopCartItems.stream().filter(shopCartItemVO -> Objects.equals(shopCartItemVO.getMold(), ProdMoldEnum.COMBO.value())).toList();
        if(CollectionUtil.isEmpty(comboShopCartItemList)){
            return;
        }
        List<Long> skuIds = comboShopCartItemList.stream().map(ShopCartItemDto::getSkuId).toList();
        List<ShopCartItemDto> comboShopItems = skuComboService.getCombShopItemsAndBySkuIds(skuIds);
        // 放入组合的所有商品信息
        Map<Long, List<ShopCartItemDto>> skuComboMap = comboShopItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getMainComboSkuId));
        for (ShopCartItemDto mainShopCartItem : shopCartItems) {
            long skuId = mainShopCartItem.getSkuId();
            if(!skuComboMap.containsKey(skuId)) {
                continue;
            }
            List<ShopCartItemDto> shopCartItemList = skuComboMap.get(skuId);

            for (ShopCartItemDto shopCartItemVO : shopCartItemList) {
                shopCartItemVO.setMainComboProdId(mainShopCartItem.getProdId());
                shopCartItemVO.setBasketId(mainShopCartItem.getBasketId());
                shopCartItemVO.setComboCount(mainShopCartItem.getProdCount());
                shopCartItemVO.setShopId(mainShopCartItem.getShopId());
                shopCartItemVO.setIsChecked(1);
            }
            assembleShopCartItem(shopCartItemList,mainShopCartItem);
            mainShopCartItem.setComboShopCartItems(shopCartItemList);
        }
    }


    private void setWarehouseList(List<ShopCartItemDto> shopCartItems, List<DvyTypeDTO> dvyTypes) {
        if (CollUtil.isEmpty(dvyTypes)) {
            return;
        }
        // 仓库分为商家仓库和供应商仓库
        // 获取快递配送的店铺Id列表
        Integer dvyType = dvyTypes.get(0).getDvyType();
        // Map<id, 类型：供应商、商家>
        Map<Long, List<WarehouseVO>> warehouseMap = new HashMap<>(dvyTypes.size() * 2);
        for (ShopCartItemDto shopCartItem : shopCartItems) {
            if (Objects.equals(shopCartItem.getMold(), ProdMoldEnum.COMBO.value())) {
                if (CollUtil.isEmpty(shopCartItem.getComboShopCartItems())) {
                    throw new YamiShopBindException("yami.prod.common.invalid");
                }
                // 组合sku列表
                for (ShopCartItemDto comboShopCartItem : shopCartItem.getComboShopCartItems()) {
                    comboShopCartItem.setStockPointId(comboShopCartItem.getStockPointList().get(0).getStockPointId());
                    shopCartItem.setStockPointType(comboShopCartItem.getStockPointList().get(0).getStockPointType());
                }
                shopCartItem.setStockPointId(shopCartItem.getComboShopCartItems().get(0).getStockPointId());
                shopCartItem.setStockPointType(shopCartItem.getComboShopCartItems().get(0).getStockPointType());
            } else if(CollectionUtil.isNotEmpty(shopCartItem.getStockPointList())){
                // 非组合商品
                shopCartItem.setStockPointId(shopCartItem.getStockPointList().get(0).getStockPointId());
                shopCartItem.setStockPointType(shopCartItem.getStockPointList().get(0).getStockPointType());
            }

            // 虚拟商品、积分商品、同城配送，都不需要获取店铺仓库列表
            boolean notWarehouse =  Objects.equals(shopCartItem.getMold(), ProdMoldEnum.VIRTUAL.value()) ||
                    Objects.equals(shopCartItem.getProdType(), ProdType.PROD_TYPE_SCORE.value());
            if (notWarehouse || Objects.equals(dvyType, DeliveryType.SAME_CITY.getValue())) {
                continue;
            }
            shopCartItem.setWarehouseList(this.listWarehouse(warehouseMap, shopCartItem));
            // 组合sku列表
            if (CollUtil.isNotEmpty(shopCartItem.getComboShopCartItems())) {
                for (ShopCartItemDto comboShopCartItem : shopCartItem.getComboShopCartItems()) {
                    comboShopCartItem.setStockPointId(comboShopCartItem.getStockPointList().get(0).getStockPointId());
                    comboShopCartItem.setStockPointType(comboShopCartItem.getStockPointList().get(0).getStockPointType());
                    comboShopCartItem.setWarehouseList(this.listWarehouse(warehouseMap, comboShopCartItem));
                }
                shopCartItem.setStockPointId(shopCartItem.getComboShopCartItems().get(0).getStockPointId());
                shopCartItem.setStockPointType(shopCartItem.getComboShopCartItems().get(0).getStockPointType());
            }
        }
    }

    private List<WarehouseVO> listWarehouse(Map<Long, List<WarehouseVO>> shopMap, ShopCartItemDto shopCartItem) {
        // 仓库列表已经查询就不重复查了，有一份数据即可
        if (shopMap.containsKey(shopCartItem.getShopId())) {
            return null;
        }
        List<WarehouseVO> warehouseList = warehouseService.listWarehouseByShopId(shopCartItem.getShopId(), SysTypeEnum.MULTISHOP.value());
        shopMap.put(shopCartItem.getShopId(), warehouseList);
        return warehouseList;
    }


}
